//
//  UIImage.swift
//  Exchange
//
//  Created by rui on 2018/7/3.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

extension UIImage {
    func compressToSize(_ size: CGSize) -> UIImage {
        UIGraphicsBeginImageContext(size)
        self.draw(in: CGRect(origin: CGPoint.zero, size: size))
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image ?? self
    }
}
